package com.sky.api.client;

import com.sky.api.client.fallback.UserFallbackFactory;
import com.sky.api.config.DefaultFeignConfig;
import com.sky.api.domain.dto.DataOverViewQueryDTO;
import com.sky.api.domain.entity.AddressBook;
import com.sky.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @author toki
 * openFeign,简化发送http请求的组件，在这里写跨服务的controller接口对应的API接口，并使用fallbackFactory进行降级处理
 */
@FeignClient(name = "user-service",
        configuration = DefaultFeignConfig.class,
        fallbackFactory = UserFallbackFactory.class)
public interface UserFeignClient {
    @GetMapping("/user/user/userStatistics")
    Result<Integer> countByMap(@RequestParam(name = "begin", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime begin,
                               @RequestParam("end") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime end);

    @GetMapping("/user/addressBook/{id}")
    Result<AddressBook> getById(@PathVariable Long id);

}